home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.002.BusyBox / busybox.c / uwindow.c < prev   
Encoding:
C/C++ Source or Header  |  1990-06-19  |  2.8 KB  |  120 lines  |  [TEXT/MPS ]

  1. /***********************************************************************
  2. *
  3. * busybox uwindow.c -- Version 3.0
  4. *
  5. * Copyright (c)
  6. * Apple Computer, Inc.  1986-1990
  7. * All Rights Reserved.
  8. *
  9. * This file contains the code which implements
  10. * windows in the busybox program.
  11. *
  12. ***********************************************************************/
  13.  
  14. #include <types.h>
  15. #include <quickdraw.h>
  16. #include <resources.h>
  17. #include <window.h>
  18.  
  19. #include "busybox.h"
  20.  
  21. extern GrafPortPtr        windowList[SHORTINDEX];
  22. extern unsigned int     staggerCount;
  23.  
  24. #define MainWindowID    0x2000L
  25.  
  26.  
  27.  
  28. /***********************************************************************
  29. *
  30. * drawThisWindow
  31. *
  32. * This routine draws the contents of all the windows.
  33. *
  34. ***********************************************************************/
  35. void    drawThisWindow()
  36. {
  37.     DrawControls(GetPort());
  38. }
  39.  
  40.  
  41.     
  42. /***********************************************************************
  43. *
  44. * doCloseTop
  45. *
  46. * This routine closes the topmost window.  We do a little work to
  47. * prevent the main window from being closed.
  48. *
  49. ***********************************************************************/
  50. void    doCloseTop()
  51. {
  52.     unsigned int    k;
  53.     GrafPortPtr     tempWin;
  54.  
  55.     tempWin = FrontWindow();
  56.         
  57.     /* Find the window entry, close the window, and zero the entry */
  58.     /* start the count at 1 since we never close the main window */
  59.     for (k = 1; k < NumWindows; k++) {
  60.         if (tempWin == windowList[k]) {
  61.             CloseWindow(tempWin);
  62.             windowList[k] = NULL;
  63.             break;
  64.         }
  65.     }
  66. }
  67.  
  68.  
  69.  
  70. /***********************************************************************
  71. *
  72. * openThisWindow
  73. *
  74. * This routine either opens the specified window or brings it to the top
  75. * if it is already open.
  76. *
  77. * If it is not open, we open it with NewWindow2 invisibly, adjust the window's
  78. * location and then show and select the window.
  79. *
  80. ***********************************************************************/
  81. void            openThisWindow(ctlid)
  82. unsigned int    ctlid;
  83. {
  84.     GrafPortPtr     wptr;
  85.  
  86.     if (!(wptr = windowList[ctlid])) {
  87.         windowList[ctlid] = wptr = NewWindow2(NULL, NULL, drawThisWindow, NULL, 2,
  88.             ctlid + MainWindowID, rWindParam1);
  89.         if (ctlid < Prog1ID) {
  90.             MoveWindow (50 + 8 * staggerCount, 50 + 8 * staggerCount, wptr);
  91.             staggerCount++;
  92.             staggerCount &= 0x0F;
  93.         }
  94.         ShowWindow(wptr);
  95.         SelectWindow(wptr);             
  96.     }
  97.     else SelectWindow(wptr);
  98. }
  99.     
  100.  
  101.     
  102. /***********************************************************************
  103. *
  104. * setupWindows
  105. *
  106. * Sets up windowList record for use through out the program.
  107. *
  108. ***********************************************************************/
  109. void    setupWindows()
  110. {
  111.     unsigned int    k;
  112.  
  113.     /* Zero out the entries in the window list. */
  114.     for (k = 0; k < NumWindows; k++) windowList[k] = NULL;
  115.  
  116.     /* Open the main window */
  117.     windowList[0] = NewWindow2(NULL, NULL, drawThisWindow, NULL, 2,
  118.         MainWindowID, rWindParam1);
  119. }
  120.